runOnStartup(async runtime => {
    cc_Game.addEventListener("minerTick", (e) => {
        MinerAnimationMpPhathonGoingDown.CameraAnimation()
    })
    cc_Game.addEventListener("minerInit", (e) => {
        MinerAnimationMpPhathonGoingDown.CameraAnimationInit()
        MinerAnimationMpPhathonGoingDown.doAnimation()
    })
});
globalThis.MinerAnimationMpPhathonGoingDown = {
    CameraAnimationInit: function () {
        /**
         * 相机锁定状态
         * @type {string}
         */
        MinerAnimationMpPhathonGoingDown.CmaeraState = "LookCar"
        cc_Game.mh_Camera.tagrCam(false)

        MinerAnimationMpPhathonGoingDown.getCamera = true
    }, CameraAnimation: function () {
        /**
         * 不同状态线下相机的视野切换
         */
        if (!MinerAnimationMpPhathonGoingDown.getCamera) return
        var mpPhathom = runtime.objects.map_Phathom.getFirstInstance()
        if (MinerAnimationMpPhathonGoingDown.CmaeraState === "LookCar") {
            runtime.layout.scrollTo(mpPhathom.x, mpPhathom.y + 350)
        }
        if (MinerAnimationMpPhathonGoingDown.CmaeraState === "LookPha") {
            runtime.layout.scrollTo(mpPhathom.x, mpPhathom.y + 500)
        }
        window.addEventListener("HookCarArrive", function doCam() {
            window.removeEventListener("mp_getarrived", doCam)
            cc_Game.mh_Camera.tagrCam(true)


            //MinerAnimationMpPhathonGoingDown.CmaeraState = "LookPha"
        })
    }, testConsole: function () {
        console.log("i am test")
    }, doAnimation: function () {
        var hook = runtime.objects.ToolHook?.getFirstInstance()
        var hookRope = runtime.objects.rope?.getFirstInstance()
        var mpPhathom = runtime.objects.map_Phathom?.getFirstInstance()
        var hookCar = runtime.objects.HookCar?.getFirstInstance()
        mpPhathom.addChild(hook, {
            transformX: true,
            transformY: true,
            transformWidth: false,
            transformHeight: false,
            transformAngle: true,
            transformZElevation: true,
            destroyWithParent: true
        })
        mpPhathom.addChild(hookRope, {
            transformX: true,
            transformY: true,
            transformWidth: false,
            transformHeight: false,
            transformAngle: true,
            transformZElevation: true,
            destroyWithParent: true
        })
        mpPhathom.addChild(hookCar, {
            transformX: true,
            transformY: true,
            transformWidth: false,
            transformHeight: false,
            transformAngle: true,
            transformZElevation: true,
            destroyWithParent: true
        })
        /**
         * @type {IMoveToBehaviorInstance}
         */
        var mpPhathomMoveBehavior = mpPhathom.behaviors.MoveTo
        var Vernier = MinerVernierSpwn.setVernier
        if (Vernier == null) {
            MinerVernierSpwn.spwn()
        }
        var goingDownPosX = mpPhathom.x
        var goingDownPosY = Vernier.y
        /**
         * 动画：
         */
        mpPhathomMoveBehavior.moveToPosition(goingDownPosX, goingDownPosY)
        mpPhathomMoveBehavior.addEventListener("arrived", function getArried() {
            mpPhathomMoveBehavior.removeEventListener("arrived", getArried)
            var e = new CustomEvent("mp_getarrived", {})
            window.dispatchEvent(e)
        })
    }
}
export default MinerAnimationMpPhathonGoingDown